<?php 
include("conf/mysqlconn.php");

$dbconf = new MysqlConnector();
$con = $dbconf->connectMySql();
if (!$con) {
    die('连接数据库失败:' . mysql_error());
}

mysql_query("set names 'utf8'"); // 解决中文乱码问题
$goodsList = mysql_query("select * from CAT");
mysql_close($con);

for($i = 0; $i < count($_FILES["resource"]["name"]); $i++){   
    $uploadfile = "uploads/" . basename($_FILES["resource"]["name"][$i]);
    if(move_uploaded_file($_FILES["resource"]["tmp_name"][$i], iconv("UTF-8","gb2312",$uploadfile))){
        echo "O了";
    }else{
        echo "搞不定啊，哥";
    }
}

?>
<!DOCTYPE html5>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
        <link href="css/global.css" rel="stylesheet" type="text/css" />
        <script src="js/jquery-1.7.2.min.js"></script>
        <script src="js/resource.js"></script>
    </head>
    <body>
        <div class="wrapper">
            <div class="fileUpload">
                <ul>
                    <?php
                    while ($row = mysql_fetch_array($goodsList)) {
                        echo "<li>";
                        echo "<span>".$row["cat_name"]."</span>";
                        echo "</li>";
                    }
                    ?>
               </ul>
                
                <form id="fileform" enctype="multipart/form-data" action="index.php" method="POST">
                    <div class="info"></div>
                    <input type="hidden" name="MAX_FILE_SIZE" value="20000000"/>
                    <input type="file" class="select" name="resource[]" multiple/>
                    <input type="button" class="submit" value="Upload" />
                </form>
            </div>
        </div>
    </body>
</html>